<%@page import="sdfi.lee.DAO.DrugDAO"%>
<%@page import="sdfi.lee.Entity.Drug"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%> 
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="<c:url value='/js/jquery-1.6.js' />"></script>
<script type="text/javascript">
	$(function(){
		$("div.newlist_date a").click(function(){
			var b=$(this);
			var option={
				url:"../deldrug.html",
				data:{did:b.attr("id")},	
				dataType:"json",
				type:"post",
				success:function(data,status){
						if(data.status=="success")
							{
								b.parents("div.newlist").remove();
							}
						else
							{
							 alert("服务器忙");
							}
				},
				error:function(xhr,data){
					 alert("出错！服务器忙");
				}
			};
			
			$.ajax(option);
			return false;
		});
		
	});
</script>
<link rel="stylesheet" href="<c:url value='/css/common.css' />" >
<title>Insert title here</title>
</head>
<body>
	
	<%
		int epid=0,pg=0;String p=request.getParameter("epid");
		//System.out.println("epid="+request.getParameter("epid"));
		//System.out.println("pg="+request.getParameter("pg"));
		if(p!=null&&!"".equals(p)) epid=Integer.valueOf(p).intValue();
		if(request.getParameter("pg")!=null) pg=Integer.valueOf(request.getParameter("pg")).intValue();
		
		List<Drug> list=new DrugDAO().getAllDrug(4,epid,pg);
		if(list!=null&&list.size()>0)
		{
			request.setAttribute("list",list);
		
	%>
	<div class="hehe">
			<c:forEach items="${requestScope.list}" var="drug" varStatus="status">
				<c:url value="/admin/drugmf.jsp?did=${drug.id}" var="durl"></c:url>
				<div class="newlist">
				<div class="newlist_title"><a href="${durl}" target="_parent">${drug.drugname}</a></div>
				<div class="newlist_date">[${drug.drugdate}] <a style="cursor:pointer" id="${drug.id}">删除</a></div>
				</div>
			</c:forEach>
	</div>
	<%
	}
		else
		{
			
	%>
		无数据！！！
	<%
		}
	%>
	<div id="pages">
		<c:if test="${param.pg!=null}">
		<c:url value="/admin/druglist.jsp?epid=${param.epid}&pg=${param.pg-1}" var="up"></c:url>
		</c:if>
			<c:url value="/admin/druglist.jsp?epid=${param.epid}&pg=${param.pg+1}" var="down"></c:url>
		<font>
			
				<c:if test="${param.pg==null||param.pg==1}">&lt;</c:if>
				<c:if test="${param.pg!=null&&param.pg!=1 }"><a href="${up}">&lt;</a></c:if>
			
		</font>
		<font>
			<c:choose>
			<c:when test="${param.pg==null||param.pg==1}">1</c:when>
			<c:otherwise>${param.pg}</c:otherwise>
		</c:choose>
		</font>
		<font>
			<c:choose>
				<c:when test="${fn:length(list)<4}">&gt;</c:when>
				<c:otherwise><a href="${down}">&gt;</a></c:otherwise>
			</c:choose>
		</font>
	</div>
</body>
</html>